package org.ruiyichen.guizhou.agr.utils;

import android.util.Log;

import org.ruiyichen.guizhou.agr.config.Constant;

/**
 * Log统一管理类
 * @author wu_tian
 */
public class L {

    private L() {
        /* cannot be instantiated */
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static boolean isDebug = Constant.App.IS_DEBUG;// 是否需要打印bug，可以在application的onCreate函数里面初始化

    // 下面四个是默认tag的函数
    public static void i(String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.i(stackElement.getClassName(), "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void d(String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.d(stackElement.getClassName(), "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void e(String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.e(stackElement.getClassName(), "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void v(String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.v(stackElement.getClassName(), "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    // 下面是传入自定义tag的函数
    public static void i(String tag, String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.i(tag, "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void d(String tag, String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.d(tag, "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void e(String tag, String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.e(tag, "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }

    public static void v(String tag, String msg) {
        if (isDebug) {
            StackTraceElement stackElement = new Throwable().getStackTrace()[1];
            if (stackElement != null) {
                Log.v(tag, "wu_tian-->" + stackElement.getMethodName() + "-->" + msg);
            }
        }
    }
}